1 /* 2 * Copyright (C) 2011 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.common.util.concurrent; 18 19 import com.google.common.annotations.GwtCompatible; 20 21 import javax.annotation.Nullable; 22 23 /** 24 * Unchecked variant of {@link java.util.concurrent.ExecutionException}. As with 25 * {@code ExecutionException}, the exception's {@linkplain #getCause() cause} 26 * comes from a failed task, possibly run in another thread. 27 * 28 * <p>{@code UncheckedExecutionException} is intended as an alternative to 29 * {@code ExecutionException} when the exception thrown by a task is an 30 * unchecked exception. However, it may also wrap a checked exception in some 31 * cases. 32 * 33 * <p>When wrapping an {@code Error} from another thread, prefer {@link 34 * ExecutionError}. When wrapping a checked exception, prefer {@code 35 * ExecutionException}. 36 * 37 * @author Charles Fry 38 * @since 10.0 39 */ 40 @GwtCompatible 41 public class UncheckedExecutionException extends RuntimeException { 42 /** 43 * Creates a new instance with {@code null} as its detail message. 44 */ 45 protected UncheckedExecutionException() {} 46 47 /** 48 * Creates a new instance with the given detail message. 49 */ 50 protected UncheckedExecutionException(@Nullable String message) { 51 super(message); 52 } 53 54 /** 55 * Creates a new instance with the given detail message and cause. 56 */ 57 public UncheckedExecutionException(@Nullable String message, @Nullable Throwable cause) { 58 super(message, cause); 59 } 60 61 /** 62 * Creates a new instance with the given cause. 63 */ 64 public UncheckedExecutionException(@Nullable Throwable cause) { 65 super(cause); 66 } 67 68 private static final long serialVersionUID = 0; 69 }